package com.bbx.taxi.client.Task;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;

import com.bbx.androidapi.util.SharedPreUtil;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.sdk.model.passanger.CouponCountBuild;
import com.bbx.api.sdk.model.passanger.LocationInfoBuild;
import com.bbx.api.sdk.model.passanger.Return.LocationInfo;
import com.bbx.api.sdk.model.passanger.Return.NearByDriver;
import com.bbx.api.sdk.model.passanger.Return.NearByDriver.DriverDetails;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Location;
import com.bbx.api.sdk.net.base.BaseNetwork;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.passeger.conn.CouponCountNet;
import com.bbx.api.sdk.net.passeger.conn.LocationInfoNet;
import com.bbx.api.sdk.net.passeger.conn.NearByDriverNet;
import com.bbx.api.util.SharedPreEncryptUtil;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Message.ObserverListener.DATA_TYPE;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.taxi.client.Util.ImageLoad.ImageLoader;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.R;

/**
 * @Path com.bbx.taxi.client.Task.MyLocationInfoTask.java
 * @Author 严旭文
 * @Date 2016-6-13 下午12:07:39
 * @Company 蓝海（福建）信息技术有限公司
 * @Description 获取位置信息
 */
public class MyLocationInfoTask extends BaseTask {
	public DATA_TYPE TYPE = DATA_TYPE.LOCATIONINFO;
	private LocationInfoBuild mLocationInfoBuild;

	public MyLocationInfoTask(Activity context, double lng, double lat,
			String province, String city) {
		super(context);
		mLocationInfoBuild = new LocationInfoBuild(context);
		mLocationInfoBuild.uid = MyApplication.getInstance().getUid();
		mLocationInfoBuild.access_token = MyApplication.getInstance()
				.getToken();
		Location mLocation = new Location();
		mLocation.lng = lng;
		mLocation.lat = lat;
		mLocationInfoBuild.cur_location = mLocation;
		mLocationInfoBuild.province = province;
		mLocationInfoBuild.city = city;
		// 保存省份跟城市
		SharedPreUtil.putStringValue(context,
				SharedPreEncryptUtil.locationcity, city);
		// 保存省份跟城市
		SharedPreUtil.putStringValue(context,
				SharedPreEncryptUtil.locationprovince, province);
	}

	@Override
	public boolean isShow() {
		return false;
	}

	@Override
	public boolean isReturnString() {
		return false;
	}
	@Override
	public boolean condition() {
		// TODO Auto-generated method stub
		return true;
	}
	@Override
	public void request() {
		setType(TYPE, mLocationInfoBuild);
	}

	@Override
	public void success(int status,Object object) {
		if (object != null) {
			LocationInfo mLocationInfo = (LocationInfo) object;
			if (mLocationInfo != null) {
				// if(mLocationInfo.getCount()!=0){
				// Value.select_num = mLocationInfo.getCount();
				// }
				if (mLocationInfo.getService_phone() != null) {
					Value.TEL_KF = mLocationInfo.getService_phone();
					Value.TEL_TSX = mLocationInfo.getService_phone();
				}
				// Value.taxi_url=mLocationInfo.getUrl();
				if (mLocationInfo.getLaunch_page() != null
						&& !mLocationInfo.getLaunch_page().equals("")) {
					ImageLoader imageLoader = new ImageLoader(context);
					imageLoader.DisplayImage(mLocationInfo.getLaunch_page(),
							null, false);
					SharedPreUtil.putStringValue(context,
							SharedPreEncryptUtil.launch_page,
							mLocationInfo.getLaunch_page());
				} else {
					SharedPreUtil.putStringValue(context,
							SharedPreEncryptUtil.launch_page, "");
				}
			}

		}

	}

	@Override
	public void failed(int status, String msg,String message) {
		// TODO Auto-generated method stub

	}

	@Override
	public BaseNetwork getBaseNetwork() {
		return new LocationInfoNet(context);
	}
}
